package com.aop;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.concurrent.TimeoutException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> handleTimeoutException(TimeoutException ex) {
        // 返回超时异常消息给前端
        return new ResponseEntity<>(HttpStatus.REQUEST_TIMEOUT);
    }
}
